<%@page import="com.hamizhong.iflowers.web.vo.GoodsTargetMapVO"%>
<%@page import="com.hamizhong.iflowers.web.vo.GoodsFestivalMapVO"%>
<%@page import="com.hamizhong.iflowers.web.vo.GoodsPurposeMapVO"%>
<%@page import="com.hamizhong.iflowers.web.vo.GoodsProductMapVO"%>
<%@page import="com.hamizhong.iflowers.web.vo.GoodsVO"%>
<%@page import="com.hamizhong.iflowers.web.vo.FlowerCountVO"%>
<%@page import="com.hamizhong.iflowers.web.vo.FlowerFloridVO"%>
<%@page import="com.hamizhong.iflowers.web.vo.TargetVO"%>
<%@page import="com.hamizhong.iflowers.web.vo.FestivalVO"%>
<%@page import="com.hamizhong.iflowers.web.vo.PurposeVO"%>
<%@page import="com.hamizhong.iflowers.web.vo.ColorVO"%>
<%@page import="com.hamizhong.iflowers.web.vo.VarietyVO"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%@include file="../common/common.jsp" %>
<link rel="stylesheet" href="<%=request.getContextPath() %>/css/index_lunbo.css">
<link rel="stylesheet" href="<%=request.getContextPath() %>/css/cat_slider.css">
<title>Hami鲜花-鲜花详情</title>
</head>

<%
	GoodsVO goodsVO = (GoodsVO)request.getAttribute("goodsVO");
	List<GoodsProductMapVO> goodsProductMapVOList = goodsVO.getGoodsProductMapVOs();
	List<GoodsPurposeMapVO> goodsPurposeMapVOList = goodsVO.getGoodsPurposeMapVOs();
	List<GoodsFestivalMapVO> goodsFestivalMapVOList = goodsVO.getGoodsFestivalMapVOs();
	List<GoodsTargetMapVO> goodsTargetMapVOList = goodsVO.getGoodsTargetMapVOs();
%>

<body>
	<%@include file="frame/top.jsp" %>
	<div class="main_div">
		<%@include file="frame/navigation.jsp" %>
		<div style="width: 990px;height: 462px;margin: 0 auto;border: 1px solid #CCC;">
			<div style="float: left;width: 462px;height: 462px;border-right: 1px solid #CCC;">
				<img width="460px" height="460px" alt="" src="<%=request.getContextPath() %>/<%=goodsVO.getGoodsPictureM() %>">
			</div>
			<div style="float: right;width: 510px;height: 460px;text-align: left;">
				<div style="width: 100%;height: 40px;line-height: 40px;font-weight: bold;">
					<font style="font-size: 16px;"><%=goodsVO.getGoodsName() %></font>
				</div>
				<div style="width: 100%;height: auto;color: #D91516;font-weight: bold;padding-bottom: 5px;border-bottom: 1px dashed #CCC;">
					<font style="font-size: 14px;"><%=goodsVO.getRemarks() %></font>
				</div>
				<div style="width:100%;height: 25px;line-height: 25px;text-align: left;font-size: 12px;">
					商品编码：<%=goodsVO.getGoodsId() %>
				</div>
				<div style="width:100%;height: 25px;line-height: 25px;text-align: left;font-size: 12px;">
					商品用途：
					<%
						for(int i=0;i<goodsPurposeMapVOList.size();i++) {
							GoodsPurposeMapVO itemVO = goodsPurposeMapVOList.get(i);
							out.print(itemVO.getPurposeVO().getPurposeName());
							if(i != goodsPurposeMapVOList.size()-1) {
								out.print("&nbsp;|&nbsp;");
							}
						}
					%>
				</div>
				<div style="width:100%;height: 25px;line-height: 25px;text-align: left;font-size: 12px;">
					鲜花主材：						
					<%
						for(int i=0;i<goodsProductMapVOList.size();i++) {
							GoodsProductMapVO itemVO = goodsProductMapVOList.get(i);
							out.print(itemVO.getProductVO().getProductName());
							if(i != goodsProductMapVOList.size()-1) {
								out.print("&nbsp;|&nbsp;");
							}
						}
					%>
				</div>
				<div style="width:100%;height: 25px;line-height: 25px;text-align: left;font-size: 12px;">
					送花节日：						
					<%
						for(int i=0;i<goodsFestivalMapVOList.size();i++) {
							GoodsFestivalMapVO itemVO = goodsFestivalMapVOList.get(i);
							out.print(itemVO.getFestivalVO().getFestivalName());
							if(i != goodsFestivalMapVOList.size()-1) {
								out.print("&nbsp;|&nbsp;");
							}
						}
					%>
				</div>
				<div style="width:100%;height: 25px;line-height: 25px;text-align: left;font-size: 12px;">
					赠送对象：						
					<%
						for(int i=0;i<goodsTargetMapVOList.size();i++) {
							GoodsTargetMapVO itemVO = goodsTargetMapVOList.get(i);
							out.print(itemVO.getTargetVO().getTargetName());
							if(i != goodsTargetMapVOList.size()-1) {
								out.print("&nbsp;|&nbsp;");
							}
						}
					%>
				</div>
				<div style="width:100%;height: 25px;line-height: 25px;text-align: left;font-size: 12px;">
					促销活动：						
					<%
						if(goodsVO.getIsBargin() == 0) {
					%>
						<font color="#999999">当前无促销</font>
					<%
						}else if(goodsVO.getIsBargin() == 1) {
					%>
						<font color="red">促销中</font>
					<%
						}
					%>
				</div>
				<div style="width:100%;height: 30px;line-height: 30px;text-align: left;font-size: 12px;">
					<%
						if(goodsVO.getIsBargin() == 0) {
					%>
						当前价格：<font color="#D91516" style="font-weight: bold;font-size: 16px;">￥<%=goodsVO.getGoodsPrice() %></font>
					<%
						}else if(goodsVO.getIsBargin() == 1) {
					%>
						活动价格：<font color="#999999">￥<%=goodsVO.getGoodsPrice() %></font>/
						<font color="#D91516" style="font-weight: bold;font-size: 16px;">￥<%=goodsVO.getBarginPrice() %></font>
					<%
						}
					%>
				</div>
				<div style="width:95%;height: 100px;line-height: 100px;text-align: left;margin-top: 10px;font-size: 16px;border: 1px solid orange;background-color: #FFEEEE">
					<div style="width: 100%;height: 40px;line-height: 40px;margin-top: 30px;text-align: left;">
						<input type="button" value="加入购物车" style="height: 40px;width: 150px;margin-left: 20px;border: none;background-color: #F44932;color: white;font-weight: bold;" onclick="addToShoppingCart(<%=goodsVO.getGoodsId()%>)">
					</div>
				</div>
			</div>
		</div>
		
		<div style="clear: both;width: 100%;height: 10px;"></div>
		<div style="width: 990px;height: auto;margin: 0 auto;overflow: hidden;">
			<div style="width: 100%;height: 30px;line-height: 30px;background: none repeat scroll 0 0 #EFEFEF;border: 1px solid #CCCCCC;">
				<font style="font-weight: bold;margin-left: 5px;">商品详情</font>
			</div>
			<div style="width: 988px;min-height: 200px;border: 1px solid #CCC;border-top: 0;">
				<div style="width: 99%;margin: 0 auto;overflow: hidden;padding-top: 5px;margin-bottom: 5px;">
					<%=goodsVO.getGoodsDescribe() %>
				</div>
			</div>
		</div>
		
		<div style="clear: both;width: 100%;height: 10px;"></div>
		<div style="width: 990px;height: auto;margin: 0 auto;overflow: hidden;">
			<div style="width: 100%;height: 30px;line-height: 30px;background: none repeat scroll 0 0 #EFEFEF;border: 1px solid #CCCCCC;">
				<font style="font-weight: bold;margin-left: 5px;">评论详情</font>
			</div>
			<div id="commentsDiv" style="width: 988px;min-height: 200px;border: 1px solid #CCC;border-top: 0;">
				
			</div>
		</div>
	</div>
	<%@include file="frame/feet2.jsp" %>
</body>

<script type="text/javascript">
	
	$(function() {
		initGoodsComments();
	});

	function initGoodsComments() {
		var goodsId = '<%=goodsVO.getGoodsId()%>';
		var pageNum = 1;
		$.ajax({
			url:'<%=request.getContextPath() %>/ajaxQueryCommentsByGoods.action',
			data:{
				"goodsId": goodsId,
				"pageNum": pageNum
			},
			type:'post',
			async: true,
			dataType: 'json',
			success: function(res) {
				var rs = res.result;
				if(rs != 0) {
					var msg = res.msg;
					alert(msg);
				}else {
					var dataHtml = '';
					var data = res.data;
					if(data.length <= 0) {
						dataHtml += '<font style="font-weight: bold;font-size: 14px;color: #999;margin-left: 5px;">当前商品下暂无评论！</font>';
					}else {
						for(var i=0;i<data.length;i++) {
							dataHtml += 
							'<div style="width: 98%;min-height: 100px;margin: 0 auto;overflow: hidden;margin-top: 5px;margin-bottom: 5px;border: 1px solid #999;">'+
								'<div style="width: 100%;height: 30px;line-height: 30px;border-bottom: 1px dashed #CCC;">'+
								'<font style="float: left;margin-left: 10px;color: green;">'+data[i].userName+'</font>'+
									'<font style="float: right;margin-right: 10px;">'+data[i].createDateStr+'</font>'+
								'</div>'+
								'<div style="width: 100%;min-height: 65px;line-height: 30px;">'+
									'<font style="padding: 10px;">'+data[i].comment+'</font>'+
								'</div>'+
							'</div>';
						}
					}
					$('#commentsDiv').html(dataHtml);
				}
			}
		});
	}

	function addToShoppingCart(goodsId) {
		var options={path:'/',expires: 1};
		$.ajax({
			url:'ajaxAddToShoppingCart.action',
			data:{
				"goodsId": goodsId
			},
			type:'post',
			async: false,
			dataType: 'text',
			success: function(msg) {
				if(msg == "failed") {
					if(confirm("该商品已经在购物车里了，是否去购物车查看？")) {
						location.href = '<%=request.getContextPath() %>/shoppingCart.action';
					}
				}else if(msg == "failedOther") {
					alert("添加购物车失败！");
				}else {
					$.cookie("iFlowers_Shopping_Cart",msg,options);
					location.href = '<%=request.getContextPath() %>/addToCartSuccessPage.action';
				}
			}
		});
	}
	
</script>

</html>